package com.fr.base.core.antlr;

public class ANTLRStringBuffer
{
  protected char[] buffer = null;
  protected int length = 0;

  public ANTLRStringBuffer()
  {
    this.buffer = new char[50];
  }

  public ANTLRStringBuffer(int paramInt)
  {
    this.buffer = new char[paramInt];
  }

  public final void append(char paramChar)
  {
    if (this.length >= this.buffer.length)
    {
      int i = this.buffer.length;
      while (this.length >= i)
        i *= 2;
      char[] arrayOfChar = new char[i];
      for (int j = 0; j < this.length; ++j)
        arrayOfChar[j] = this.buffer[j];
      this.buffer = arrayOfChar;
    }
    this.buffer[this.length] = paramChar;
    this.length += 1;
  }

  public final void append(String paramString)
  {
    for (int i = 0; i < paramString.length(); ++i)
      append(paramString.charAt(i));
  }

  public final char charAt(int paramInt)
  {
    return this.buffer[paramInt];
  }

  public final char[] getBuffer()
  {
    return this.buffer;
  }

  public final int length()
  {
    return this.length;
  }

  public final void setCharAt(int paramInt, char paramChar)
  {
    this.buffer[paramInt] = paramChar;
  }

  public final void setLength(int paramInt)
  {
    if (paramInt < this.length)
      this.length = paramInt;
    else
      while (paramInt > this.length)
        append(');
  }

  public final String toString()
  {
    return new String(this.buffer, 0, this.length);
  }
}